
const pool = require('../../mysql/Dao/sql')
const newswebService={
    GetNewsList:async ()=>{
     try{
        const params =[]
        const sql = 'select * from news where isPublish=1 order by editTime desc'
        return await pool(sql,params)
     }
     catch(err){
        return {err:err,code:400}
     }
    },
    SearchNews:async (data)=>{
        try{
           const params =['%'+data+'%']
           const sql = 'select * from news where title like ? and isPublish=1'
           return await pool(sql,params)
        }
        catch(err){
           return {err:err,code:400}
        }
       },
       GetNewNewsList:async (limit)=>{
         try{
            const params =[limit]
            const sql = 'SELECT * FROM news where isPublish=1 ORDER BY editTime DESC LIMIT ?;'
            return await pool(sql,params)
         }
         catch(err){
            return {
               err:err,code:400
            }
         }
       }
}
module.exports = newswebService